package com.xuhuan.example.example032;

import com.xuhuan.example.util.ExampleArrayUtils;

/**
 * @author: huan.xu
 * @create: 2023/11/13 16:23
 * @description:
 **/
public class Example032 {
    public static void main(String[] args) {
        int[][] array = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

        System.out.println("行和列互换前：");
        ExampleArrayUtils.printArray(array);

        int[][] arrayAfter = new int[array.length][array.length];
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                arrayAfter[i][j] = array[j][i];
            }
        }

        System.out.println("行和列互换后：");
        ExampleArrayUtils.printArray(arrayAfter);
    }
}
